package cn.yunhe.action;

import cn.yunhe.eneity.Emp;
import cn.yunhe.service.impl.EmpService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import lombok.Getter;
import lombok.Setter;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;

import java.util.List;
import java.util.Map;

@Getter
@Setter
@Controller
@ParentPackage(value = "struts-default")
public class EmpAction extends ActionSupport {

    @Autowired
    @Qualifier(value = "empService")
    private EmpService empService;


    @Action(value = "aa",results={
            @Result(location = "/emps.jsp")
    })
    public String cha() throws Exception {
        List<Emp> list = empService.getAllEmps();
        Map request = (Map) ActionContext.getContext().get("request");
        request.put("list", list);

        return SUCCESS;
    }
}
